package com.fottas.adware.core;

import cn.hutool.core.util.StrUtil;
import com.fottas.adware.payment.app.model.WXPayRequest;

import java.util.Map;

public class Context {

    /**
     * 客户端配置参数
     */
    private final Map<String, String> config;

    /**
     * 证书模式运行时环境
     */
    private CertEnvironment certEnvironment;

    public Context(WXConfig options) {
        this.config = BaseModel.buildMap(options);
        if (StrUtil.isNotBlank(getConfig(WxConstants.CERTPATH))) {
            certEnvironment = new CertEnvironment(getConfig(WxConstants.CERTPATH),
                    getConfig(WxConstants.CERTPASS));
        }
    }

    public String getConfig(String key) {
        return config.get(key);
    }

    public Map<String, String> getConfigs() {
        return config;
    }

    public CertEnvironment getCertEnvironment() {
        return certEnvironment;
    }
}
